﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ElectronicJournal
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                //перенаправление авторизованного пользователя на страницу, соответствующую его роли
                //if (System.Web.HttpContext.Current.User.IsInRole("Administrator"))
                //{
                //    MasterPageFile = "~/Admin/AdminSite.Master";
                //}
                //else if (System.Web.HttpContext.Current.User.IsInRole("Author"))
                //{
                //    MasterPageFile = "~/Account/AuthorAccount/AuthorSite.Master";
                //}
                //else if (System.Web.HttpContext.Current.User.IsInRole("Editor"))
                //{
                //    MasterPageFile = "~/Account/EditorAccount/EditorSite.Master";
                //}
                //else if (System.Web.HttpContext.Current.User.IsInRole("Reviewer"))
                //{
                //    MasterPageFile = "~/Account/ReviewerAccount/ReviewerSite.Master";
                //}
            }
            else
            {
                //MasterPageFile = "~/Site.Master";
            }
        }

        protected void ShowPublicationsPanel(object sender, EventArgs e)
        {
            //JournalsPanel.Visible = false;
            //PublicationsPanel.Visible = true;
            //JournalIdLabel.Text = GridViewJournal.SelectedDataKey.Value.ToString();
            //SqlDataSource3.SelectParameters[0].DefaultValue = GridViewJournal.SelectedDataKey.Value.ToString();
        }

        protected void GoToJournalLIst(object sender, EventArgs e)
        {
            //JournalIdLabel.Text = "";
            //JournalsPanel.Visible = true;
            //PublicationsPanel.Visible = false;
        }

        protected void GoToPublicationsList(object sender, EventArgs e)
        {
            //PublicationInfoPanel.Visible = false;
            //PublicationsPanel.Visible = true;
        }

        protected void ShowPublicationInfo(object sender, EventArgs e)
        {
            //CurrentPublicationId.Text = GridViewPublications.SelectedDataKey.Value.ToString();
            //DB.DbPublications db = new DB.DbPublications();
            //DB.Item.ItemPublication item = db.GetPublicationById(GridViewPublications.SelectedDataKey.Value.ToString());
            //TitleRussianLabel.Text = item.TitleRussian;
            //TitleEnglishLabel.Text = item.TitleEnglish;
            //FileArtickeLinkButton.Text = item.FileArticle;
            //FileArtickeLinkButton.Visible = System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            //ScientificDirectionLabel.Text = db.GetScientificDirection(item.ScientificDirection);
            //TypeLabel.Text = db.GetType(item.Type);
            //UDCIndexLabel.Text = db.GetUDCIndex(item.UDCIndex);
            //SpecialityLabel.Text = item.Speciality;
            //SummaryRussianTextBox.Text = item.SummaryRussian;
            //SummaryEnglishTextBox.Text = item.SummaryEnglish;
            //KeywordRussianTextBox.Text = item.KeywordsRussian;
            //KeywordEnglishTextBox.Text = item.KeywordsEnglish;
            //PublicationsPanel.Visible = false;
            //PublicationInfoPanel.Visible = true;
            //SqlDataSource4.SelectParameters[0].DefaultValue = GridViewPublications.SelectedDataKey.Value.ToString();
        }

        protected void FileLinkButton_Click(object sender, EventArgs e)
        {
            //DB.Item.ItemPublication item = new DB.DbPublications().GetPublicationById(CurrentPublicationId.Text);
            //HttpContext.Current.Response.ContentType = "APPLICATION/OCTET-STEAM";
            //string Header = "Attachment; Filename=" + item.FileArticle;
            //HttpContext.Current.Response.AppendHeader("Content-Disposition", Header);
            //System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("\\Account\\files\\publications\\") + item.FileArticle);
            //HttpContext.Current.Response.WriteFile(file.FullName);
            //HttpContext.Current.Response.End();
        }
    }
}
